﻿using FastData;
using M6R小圆柱注液机.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace M6R小圆柱注液机.Pages
{
    public partial class ChartPage : Form
    {
        public ChartPage()
        {
            InitializeComponent();

            TopLevel = false;
        }

        private void ChartPage_Load(object sender, EventArgs e)
        {
            userChart1.InitChartset();
            userChart1.MinY = -20;//曲线图纵坐标最小值
            userChart1.MaxY = 120;//曲线图纵坐标最大值
            userChart1.DownValue = Convert.ToSingle(SaveStatic.ReadIni(GlobalValues.PathVariable.fileCommonPara, "MainPage_Para", "NoteLiquidWeightMin"));//注液量 下限
            userChart1.UpValue = Convert.ToSingle(SaveStatic.ReadIni(GlobalValues.PathVariable.fileCommonPara, "MainPage_Para", "NoteLiquidWeightMax"));//注液量 上限

            //CPK补偿值刷新
            Timer tChartData = new Timer();
            tChartData.Interval = 1000;
            tChartData.Tick += tChartData_Tick;
            tChartData.Start();

        }

        private void tChartData_Tick(object sender, EventArgs e)
        {
            userChart1.LineName[0] = "1_1针头";
            userChart1.LineName[1] = "1_2针头";
            userChart1.LineName[2] = "2_1针头";
            userChart1.LineName[3] = "2_2针头";
            userChart1.LineName[4] = "3_1针头";
            userChart1.LineName[5] = "3_2针头";

            userChart1.ListDataBinToTxt[0] = GlobalValues.PathVariable.fileNeedle_1Value;
            userChart1.ListDataBinToTxt[1] = GlobalValues.PathVariable.fileNeedle_2Value;
            userChart1.ListDataBinToTxt[2] = GlobalValues.PathVariable.fileNeedle_3Value;
            userChart1.ListDataBinToTxt[3] = GlobalValues.PathVariable.fileNeedle_4Value;
            userChart1.ListDataBinToTxt[4] = GlobalValues.PathVariable.fileNeedle_5Value;
            userChart1.ListDataBinToTxt[5] = GlobalValues.PathVariable.fileNeedle_6Value;

            userChart1.fresh();
        }

        /// <summary>
        /// Y轴坐标放大
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            if (userChart1.MaxY > userChart1.MinY + 0.03)
            {
                userChart1.MaxY -= 0.01;
                userChart1.MinY += 0.01;
                userChart1.IntervalY = (userChart1.MaxY - userChart1.MinY) / 20d;
            }
        }

        /// <summary>
        /// Y轴坐标缩小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            userChart1.MaxY += 0.01;
            userChart1.MinY -= 0.01;
            userChart1.IntervalY = (userChart1.MaxY - userChart1.MinY) / 20d;
        }


        /// <summary>
        /// X轴加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            userChart1.ShowCount += 5;
            userChart1.IntervalX = userChart1.ShowCount / 20;
        }

        /// <summary>
        /// X轴减
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (userChart1.ShowCount > 20)
            {
                userChart1.ShowCount -= 5;
                userChart1.IntervalX = userChart1.ShowCount / 20;
            }
        }

    }
}
